package com.zy.edu.controller;


import com.zy.edu.bean.CourseChapterHomeworkStu;
import com.zy.edu.bean.InputParam;
import com.zy.edu.bean.CourseChapterHomework;
import com.zy.edu.service.CourseChapterHomeworkService;
import com.zy.edu.service.CourseChapterHomeworkStuService;
import com.zy.edu.service.CourseChapterHomeworkService;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author HuangHaiShui
 * @since 2021-08-26
 */
@RestController
@RequestMapping("/homework")
public class CourseChapterHomeworkController {

    @Resource
    CourseChapterHomeworkService courseChapterHomeworkService;
    
    @Resource
    CourseChapterHomeworkStuService courseChapterHomeworkStuService;

    @RequestMapping("/edit")
    public Map edit(@Valid CourseChapterHomework courseChapterHomework, InputParam inputParam){
        return courseChapterHomeworkService.saveOrUpdate(courseChapterHomework,inputParam);
    }

    @RequestMapping("/list")
    public Map list(CourseChapterHomework courseChapterHomework, InputParam inputParam){
        return courseChapterHomeworkService.list(courseChapterHomework, inputParam);
    }

    @RequestMapping("/getById")
    public Map getById(CourseChapterHomework courseChapterHomework, InputParam inputParam){
        return courseChapterHomeworkService.getById(courseChapterHomework, inputParam);
    }

    //仅是课时界面，课时作业（未发布）的数据删除
    @RequestMapping("/dele")
    public Map dele( CourseChapterHomework courseChapterHomework){
        return courseChapterHomeworkService.dele(courseChapterHomework);
    }

    @RequestMapping("/delePublish")
    public Map delePublish( CourseChapterHomework courseChapterHomework){
        return courseChapterHomeworkService.delePublish(courseChapterHomework);
    }


    //单个课时作业发布给学生
    @RequestMapping("/publish")
    public Map publish( CourseChapterHomework courseChapterHomework, InputParam inputParam){
        return courseChapterHomeworkService.publish(courseChapterHomework,inputParam);
    }
    //老师登录后，已发布的作业列表
    @RequestMapping("/listByCls")
    public Map listByCls( CourseChapterHomework courseChapterHomework, InputParam inputParam){
        return courseChapterHomeworkService.listByCls(courseChapterHomework,inputParam);
    }



    ////////////////////////学生作业相关////////////////////////////////
    //学生作业的上传
    @RequestMapping("/submit")
    public Map sub(CourseChapterHomeworkStu courseChapterHomeworkStu, InputParam inputParam){
        return courseChapterHomeworkStuService.submit(courseChapterHomeworkStu, inputParam);
    }
    //学生获取自己作业
    @RequestMapping("/getByStuId")
    public Map getByStuId( InputParam inputParam){
        return courseChapterHomeworkStuService.getByStuId( inputParam);
    }

    ///////////////////////老师批改作业////////////////////////
    //批改作业
    @RequestMapping("/correct")
    public Map correct(CourseChapterHomeworkStu courseChapterHomeworkStu, InputParam inputParam){
        return courseChapterHomeworkStuService.correct(courseChapterHomeworkStu, inputParam);
    }

    //作业列表
    //教师一定要传入班级id，默认为查询未批改的作业
    @RequestMapping("/getCommitList")
    public Map getByClsId(CourseChapterHomeworkStu courseChapterHomeworkStu, InputParam inputParam){
        return courseChapterHomeworkStuService.getByClsId(courseChapterHomeworkStu, inputParam);
    }
}

